<?php

/**
 * Application form base class.
 *
 * @method Application getObject() Returns the current form's model object
 *
 * @package    KC-INDICATEURS
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseApplicationForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'categorie_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Categorie'), 'add_empty' => false)),
      'projet_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Projet'), 'add_empty' => false)),
      'nom_court'       => new sfWidgetFormInputText(),
      'nom'             => new sfWidgetFormInputText(),
      'recette_version' => new sfWidgetFormInputText(),
      'recette_date'    => new sfWidgetFormDate(),
      'prod_version'    => new sfWidgetFormInputText(),
      'prod_date'       => new sfWidgetFormDate(),
      'commentaire'     => new sfWidgetFormTextarea(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'categorie_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Categorie'))),
      'projet_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Projet'))),
      'nom_court'       => new sfValidatorString(array('max_length' => 64)),
      'nom'             => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'recette_version' => new sfValidatorString(array('max_length' => 64, 'required' => false)),
      'recette_date'    => new sfValidatorDate(array('required' => false)),
      'prod_version'    => new sfValidatorString(array('max_length' => 64, 'required' => false)),
      'prod_date'       => new sfValidatorDate(array('required' => false)),
      'commentaire'     => new sfValidatorString(array('max_length' => 1024, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('application[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Application';
  }

}
